package com.xrtn.controller;

import com.xrtn.bean.InitLabelInfo;
import com.xrtn.bean.InitLabelTypeInfo;
import com.xrtn.service.ILabelService;
import com.xrtn.utils.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by tu_pei on 2018/5/22.
 */
@Api("基础数据模块")
@Controller
@CrossOrigin(origins = "*", maxAge = 3600)
@RequestMapping("/label")
public class LabelController {

    @Autowired
    private ILabelService labelService;

    /**
     * @Title: saveLabelTypeInfo
     * @Description: 新增标签类型
     * @param @param initLabelTypeInfo
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "新增标签类型",notes="新增标签类型")
    @RequestMapping(value = "/saveLabelTypeInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData saveLabelTypeInfo(InitLabelTypeInfo initLabelTypeInfo){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.insertTypeSelective(initLabelTypeInfo));
        // 返回数据
        return data;
    }

    /**
     * @Title: selectLabelTypeInfo
     * @Description: 查询标签类型
     * @param @param typeId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询标签类型",notes="查询标签类型")
    @RequestMapping(value = "/selectLabelTypeInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectLabelTypeInfo(Integer typeId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.selectTypeByPrimaryKey(typeId));
        // 返回数据
        return data;
    }

    /**
     * @Title: updateLabelTypeInfo
     * @Description: 修改标签类型
     * @param @param initLabelTypeInfo
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "修改标签类型",notes="修改标签类型")
    @RequestMapping(value = "/updateLabelTypeInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData updateLabelTypeInfo(InitLabelTypeInfo initLabelTypeInfo){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.updateTypeByPrimaryKeySelective(initLabelTypeInfo));
        // 返回数据
        return data;
    }

    /**
     * @Title: deleteLabelTypeInfo
     * @Description: 删除标签类型
     * @param @param typeId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "删除标签类型",notes="删除标签类型")
    @RequestMapping(value = "/deleteLabelTypeInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData deleteLabelTypeInfo(Integer typeId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.deleteTypeByPrimaryKey(typeId));
        // 返回数据
        return data;
    }



    /**
     * @Title: saveLabelInfo
     * @Description: 新增标签
     * @param @param initLabelInfo
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "新增标签",notes="新增标签")
    @RequestMapping(value = "/saveLabelInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseData saveLabelInfo(InitLabelInfo initLabelInfo){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.insertInfoSelective(initLabelInfo));
        // 返回数据
        return data;
    }

    /**
     * @Title: selectLabelInfo
     * @Description: 查询标签
     * @param @param labelId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "查询标签",notes="查询标签")
    @RequestMapping(value = "/selectLabelInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData selectLabelInfo(Integer labelId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.selectInfoByPrimaryKey(labelId));
        // 返回数据
        return data;
    }

    /**
     * @Title: updateLabelInfo
     * @Description: 修改标签类型
     * @param @param initLabelTypeInfo
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "修改标签类型",notes="修改标签类型")
    @RequestMapping(value = "/updateLabelInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData updateLabelInfo(InitLabelInfo initLabelInfo){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.updateInfoByPrimaryKeySelective(initLabelInfo));
        // 返回数据
        return data;
    }

    /**
     * @Title: deleteLabelInfo
     * @Description: 删除标签类型
     * @param @param typeId
     * @param @return
     * @return ResponseData
     * @throws
     */
    @ApiOperation(value = "删除标签类型",notes="删除标签类型")
    @RequestMapping(value = "/deleteLabelInfo",method = RequestMethod.GET)
    @ResponseBody
    public ResponseData deleteLabelInfo(Integer labelId){

        // 创建响应Model
        ResponseData data = new ResponseData();
        // 调用Service

        data.setResults(labelService.deleteInfoByPrimaryKey(labelId));
        // 返回数据
        return data;
    }



}
